package com.codeyang.config;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 描述: 自定义的线程池
 * 后台管理系统的线程池
 *
 * @author CodeYang_Site
 * @version 2021/5/24 16:15
 */
public class ManagerThreadPool {

    public static ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(
            4, //核心线程数,我的电脑垃圾只有4核
            Runtime.getRuntime().availableProcessors(),//最大可用线程数
            30,//线程存活时间
            TimeUnit.SECONDS, //时间单位
            new LinkedBlockingQueue<>(30),//任务阻塞队列
            Executors.defaultThreadFactory(),//线程工厂
            new ThreadPoolExecutor.AbortPolicy()//拒绝策略
    );
}
